//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web;

namespace CommunityServer.Components.HttpHandler
{
	/// <summary>
	/// Summary description for InkHandler.
	/// </summary>
	public class InkHandler : IHttpHandler
	{
		public InkHandler()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		public void ProcessRequest(HttpContext context)
		{
			CSContext csContext = CSContext.Current;
			int inkID = csContext.GetIntFromQueryString("inkid", -1);
			if(inkID > 0)
			{
				//.Get will apply section level security
				InkData data = Ink.Get(inkID);
				if(data != null)
				{
					context.Response.ClearContent();
					context.Response.ContentType = "image/gif";
					context.Response.Cache.SetLastModified(data.DateUpdated);
					context.Response.BinaryWrite(data.GetBytes());
				}
			}
		}

		public bool IsReusable
		{
			get { return true; }
		}
	}
}
